package com.example.traffic_learning;

import global.AsyncResponse;
import android.os.AsyncTask;
import android.text.Html;
import android.text.Spanned;
import android.text.SpannedString;

public class ConvertText extends AsyncTask<String, Integer, Spanned>{

	public AsyncResponse delegate = null;
	private int index = 0;
	public ConvertText(int index){
		this.index = index;
	}
	@Override
	protected Spanned doInBackground(String... arg0) {
		/*boolean isContinue = false;
		try{
			isContinue = FragLawTrafficLearning.isContinue.getElementByTag(index);
		}catch(Exception e){}
		while(isContinue == false){
			try {
				Thread.sleep(100);
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}*/
		Spanned spanned;
		spanned = new SpannedString(Html.fromHtml(arg0[0]));
		return spanned;
	}

	@Override
	protected void onPreExecute(){
		super.onPreExecute();
		
	}
	protected void onPostExecute(Spanned result){
		super.onPostExecute(result);
		//FragLawTrafficLearning.isContinue.add(true, index+1);
		delegate.processConvertTextFinish(result, index);
	}
}
